//package com.mininglamp.interceptor;
//
//import java.io.PrintWriter;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//
//import org.apache.commons.lang.StringUtils;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import com.mininglamp.model.User;
//
//public class LoginHanderInterceptor implements HandlerInterceptor {
//
//	//不对匹配该值的访问路径拦截（正则）,此外还需要在ApplicationContext.xml中的shiroFilter中将该路径配置一下
//   public static final String NO_INTERCEPTOR_PATH = "(.*/((login)|(userlogin)|(userTologin)|(PKITologin)|(logout)|(static)).*)|(/dwjk/.*)|(/login/.*)|(/download/.*)";
//   public static final String SESSION_USER = "user";//session 中存放用户信息的key
//   public static final String PKILOGIN = "";
//	@Override
//	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
//			throws Exception {
//		String path = request.getServletPath();
//		if(path.matches(NO_INTERCEPTOR_PATH)) {
//			return true;
//		}else {
//			HttpSession session = (HttpSession)request.getSession();
//			User user = (User)session.getAttribute(SESSION_USER);
//			if(user!=null) {
//				return true;
//			}else {
//				String requestType = request.getHeader("X-Requested-With");
//				if(StringUtils.isNotBlank(requestType)) {
//					PrintWriter out = null;
//					
//					try {
//						response.setContentType("text/html;chartset=utf-8");
//						request.setAttribute("FILTERRESULT", "not_online");
//						out = response.getWriter();
//						out.write("{'success':false, 'content':'not_online'}");
//					} finally{
//						if(out!=null) {
//							out.close();
//						}
//                       }
//				}else {
//					//登陆过滤
//					response.sendRedirect(PKILOGIN);
//				}
//				return false;
//			}
//		}
//		
//	}
//
//	@Override
//	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
//			ModelAndView modelAndView) throws Exception {
//		// TODO Auto-generated method stub
//		
//	}
//
//	@Override
//	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
//			throws Exception {
//		// TODO Auto-generated method stub
//		
//	}
//
//}
